﻿using System;
using System.Drawing;

using BLL;
using Utility;

namespace EvaluationSystem
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        private string username = string.Empty;
        private string enterpriseId = string.Empty;
        private EnterpriseUserBLL enterpriseUser = new EnterpriseUserBLL();
       
        protected void Page_Load(object sender, EventArgs e)
        {
            ((SiteEnterpriseMaster)Master).InitMenu();
            ((SiteEnterpriseMaster)Master).li2.Attributes.Add("class", "hover ccc");
            ((SiteEnterpriseMaster)Master).b_hmenu1.Style.Add("display", "none");
            ((SiteEnterpriseMaster)Master).b_hmenu2.Style.Clear();
            ((SiteEnterpriseMaster)Master).b_hmenu3.Style.Add("display", "none");
            ((SiteEnterpriseMaster)Master).b_hmenu4.Style.Add("display", "none");
            ((SiteEnterpriseMaster)Master).s_menu2_4.Style.Add("COLOR", "#147ab8");
            ((SiteEnterpriseMaster)Master).s_menu2_4.Style.Add("TEXT-DECORATION", "none");

            if (Session["username"] == null)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script>alert('请先登录系统!');top.location.href='../Enterprise/EnterpriseLogin.aspx';</script>");
                return;
            }
            else
            {
                username = Session["username"].ToString();
            }
        }

        protected void btnChange_Click(object sender, EventArgs e)
        {
            int result = enterpriseUser.UpdatePassword(username, txtNewPwdA.Text.Trim());

            if (result == 1)
            {
                //lblMessage.ForeColor = Color.Blue;
                //lblMessage.Text = "密码修改成功";
                //txtNewPwd.Text = "";
                //txtNewPwdA.Text = "";
                //txtOldPwd.Text = "";
                MessageBox.ShowAndRedirect(this, "密码修改成功，请使用新密码进行登录!", "EnterpriseLogin.aspx");
            }
        }
    }
}